package com.jinzihan.service.impl;

import com.jinzihan.dao.StudentDao;
import com.jinzihan.dao.impl.StudentDaoImpl;
import com.jinzihan.entity.Student;
import com.jinzihan.service.StudentService;

public class StudentServiceImpl implements StudentService {
    StudentDao studentDao = new StudentDaoImpl();

    @Override
    public Student login(Student student) {
        return studentDao.queryStudentByUsernameAndPassword(student.getUsername(),student.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        return studentDao.queryStudentByUsername(username)==null?false:true;
    }

    @Override
    public int queryUserId(String name) {
        Student student = studentDao.queryStudentByUsername(name);
        return student.getStudentId();
    }

    @Override
    public String queryUsernameById(Integer id) {
        Student student = studentDao.queryStudentById(id);
        return student.getUsername();
    }
}
